import React from 'react'
import LwjTable from 'components/LwjTable/LwjTable'
import { financialBusinessType } from "utils/enumConfig"
import moment from 'moment';

const List = ({
  ...tableProps
}) => {
  const columns = [
    {
      title: '单据编号',
      dataIndex: 'num',
      key: 'num',
      width: "10%",
    },
    {
      title: '客户姓名',
      dataIndex: 'customerName',
      key: 'customerName',
      width: "4%",
    },
    {
      title: '变化之前余额(元)',
      dataIndex: 'balanceOld',
      key: 'balanceOld',
      width: "10%",
      render: (text, record, index) => (record.balanceOld.toFixed(2))
    },
    {
      title: '变动余额(元)',
      dataIndex: 'purseBillMoney',
      key: 'purseBillMoney',
      width: "10%",
      render: (text, record, index) => (
        <span>
          {record.purseBillType === "ADD" && <span style={{ color: 'green' }}>+{record.purseBillMoney.toFixed(2)}</span>}
          {record.purseBillType === "SUBTRACT" && <span style={{ color: 'red' }}>-{record.purseBillMoney.toFixed(2)}</span>}
        </span>
      )
    },
    {
      title: '变化之后余额(元)',
      dataIndex: 'balanceNew',
      key: 'balanceNew',
      width: "10%",
      render: (text, record, index) => (
        record.balanceNew.toFixed(2)
      )
    },
    {
      title: '变动时间',
      dataIndex: 'createTime',
      key: 'createTime',
      width: "14%",
      render: (text, record, index) => (moment(record.createTime).format("YYYY-MM-DD HH:mm:ss"))
    },
    {
      title: '业务类型',
      dataIndex: 'businessType',
      key: 'businessType',
      width: "12%",
      render: (text, record, index) => (financialBusinessType[record.businessType])
    },
    {
      title: '备注',
      dataIndex: 'memo',
      key: 'memo',
      width: "34%",
      render: (text, record, index) => (record.memo === null ? "暂无备注" : record.memo)
    }
  ];

  return (
    <div>
      <LwjTable
        {...tableProps}
        columns={columns}
      />
    </div>
  )
};

export default List
